//
//  Section.m
//  NewsReader
//
//  Created by blacksun on 10-10-17.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Section.h"


@implementation Section

@synthesize sectionId;
@synthesize sectionName;
@synthesize imageUrl;
@synthesize summary;
@synthesize lastFeedTitle;
@synthesize lastFeedImageUrl;
@synthesize refreshDate;
@synthesize currentMaxId;
@synthesize currentMinId;
@synthesize leaf;
@synthesize childSections;
@synthesize icon;
@synthesize isNewest;
@synthesize oldImageUrl;
@synthesize oldFeedTitle;

 
- (void)encodeWithCoder:(NSCoder *)encoder{
	[encoder encodeObject:sectionId forKey:kSection_SectionId];
	[encoder encodeObject:sectionName forKey:kSection_SectionName];
	[encoder encodeObject:imageUrl forKey:kSection_ImageUrl];
	[encoder encodeObject:summary forKey:kSection_Summary];
	[encoder encodeObject:lastFeedTitle forKey:kSection_LastFeedTitle];
	[encoder encodeObject:lastFeedImageUrl forKey:kSection_LastFeedImageUrl];
	[encoder encodeObject:refreshDate forKey:kSection_RefreshDate];
	[encoder encodeInt64:currentMaxId forKey:kSection_CurrentMaxId];
	[encoder encodeInt64:currentMinId forKey:kSection_CurrentMinId];
	[encoder encodeObject:oldImageUrl forKey:kSection_OldFeedImage];
	[encoder encodeObject:oldFeedTitle forKey:kSection_OldFeedTitle];
    [encoder encodeObject:childSections forKey:kSection_ChildSections];
    //NSLog(@"encode:old=%@",self.oldImageUrl);
	
}
- (id)initWithCoder:(NSCoder *)decoder{
	if (self = [super init]) {	
		self.sectionId = [decoder decodeObjectForKey:kSection_SectionId];
		self.sectionName = [decoder decodeObjectForKey:kSection_SectionName];
		self.imageUrl = [decoder decodeObjectForKey:kSection_ImageUrl];
		self.summary = [decoder decodeObjectForKey:kSection_Summary];
		self.lastFeedTitle = [decoder decodeObjectForKey:kSection_LastFeedTitle];
		self.lastFeedImageUrl = [decoder decodeObjectForKey:kSection_LastFeedImageUrl];
		self.refreshDate = [decoder decodeObjectForKey:kSection_RefreshDate];
		self.currentMaxId = [decoder decodeInt64ForKey:kSection_CurrentMaxId];
		self.currentMinId = [decoder decodeInt64ForKey:kSection_CurrentMinId];
		self.oldImageUrl = [decoder decodeObjectForKey:kSection_OldFeedImage];
		self.oldFeedTitle = [decoder decodeObjectForKey:kSection_OldFeedTitle];
        self.childSections = [decoder decodeObjectForKey:kSection_ChildSections];
        //NSLog(@"decoder:old=%@",self.oldImageUrl);
	}
	return self;
}



-(void)dealloc{
	[self.sectionId release];
	[self.sectionName release];
	[self.imageUrl release];
	[self.summary release];
	[self.lastFeedTitle release];
	[self.lastFeedImageUrl release];
	[self.refreshDate release];
	[self.childSections release];
	[self.icon release];
	[self.oldImageUrl release];
	[self.oldFeedTitle release];
	[super dealloc];
}

@end